home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / a86b.arc / SEGMENTS.DOC < prev    next >
Encoding:
Text File  |  1986-06-22  |  2.4 KB  |  59 lines

  1. ---SEGMENTS.DOC---
  2.  
  3. Segments in A86
  4.  
  5. A86 views the 86 computer's memory space as having two parts: The first part is
  6. the program, whose contents are the object bytes generated by A86 during its
  7. assembly of the source.   A86 calls this area the CODE SEGMENT.  The second part
  8. is the data area, whose contents are generated by the program after it starts
  9. running.  A86 calls this area the DATA SEGMENT.
  10.  
  11. Please note well that the only difference between the CODE and DATA segments is
  12. whether the contents are generated by the program or the assembler.  The names
  13. CODE and DATA suggest that program code is placed in the CODE segment, and data
  14. structures go in the DATA segment.  This is mostly true, but there are
  15. exceptions.  For example, there are many data structures whose contents are
  16. determined by the assembler: pointer tables, arrays of pre-defined constants,
  17. etc.  These tables are assembled in the CODE segment.
  18.  
  19. In general, you will want to begin your program with the directive DATA SEGMENT,
  20. followed by an ORG statement giving the address of the start of your data area.
  21. You then list all your program variables and uninitialized data structres, using
  22. the directives DB, DW, and STRUC.  A86 will allocate space starting at the
  23. address given in the ORG statement, but it will not generate any object bytes in
  24. that space.  After your data segment declarations, you provide a CODE SEGMENT
  25. directive, following by an ORG giving the address of the start of your program.
  26. You follow this with the program itself, together with any assembler-generated
  27. data structures.  A short program illustrating this suggested usage follows:
  28.  
  29. DATA SEGMENT
  30. ORG 08000
  31.   ANSWER_BYTE  DB ?
  32.   CALL_COUNT   DW ?
  33.  
  34. CODE SEGMENT
  35.   JMP MAIN
  36.  
  37. TRAN_TABLE:
  38.   DB 16,3,56,23,0,9,12,7
  39.  
  40. MAIN:
  41.   MOV BX,TRAN_TABLE
  42.   XLATB
  43.   MOV ANSWER_BYTE,AL
  44.   INC CALL_COUNT
  45.   RET
  46.  
  47. A86 allows you to intersperse CODE SEGMENTs and DATA SEGMENTs throughout yuor
  48. program; but in general it is best to put all your DATA SEGMENT declarations at
  49. the top of your program, to avoid problems with forward-referencing.
  50.  
  51.  
  52. CODE ENDS and DATA ENDS Statements
  53.  
  54. For compatibility with Intel/IBM assemblers, A86 provides the CODE ENDS and
  55. DATA ENDS statements.  The CODE ENDS statement is ignored; we assume that you
  56. have not nested a CODE segment inside a DATA segment.  The DATA ENDS statement
  57. is equivalent to a CODE SEGMENT statement.
  58.  
  59.